﻿<UserControl x:Class="XWord.WPF.ApplicationFramework.TestModules.validationsimple.CompareValidatorSimple"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:validations="http://schemas.xword.com/winfx/xaml/info"
             xmlns:behaviors="http://schemas.xword.com/winfx/xaml/info"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <TabControl>

            <TabItem Header="PassWordMatch2">
                <Canvas>
                    <Label Canvas.Left="6" Canvas.Top="37" Height="28" Content="{Binding BindablePropertyItem,ElementName=passwordBox1Action}" />
                    <Label Canvas.Left="6" Canvas.Top="72" Content="再次输入密码" Height="28" />
                    <PasswordBox Canvas.Left="105" Canvas.Top="39" Height="23" Name="passwordBox1" Width="120">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="PasswordChanged">
                                <behaviors:ReadOnlyPropertyAction x:Name="passwordBox1Action" Property="Password"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </PasswordBox>
                    <PasswordBox Canvas.Left="105" Canvas.Top="72" Height="23" Name="passwordBox2" Width="120">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="PasswordChanged">
                                <behaviors:ReadOnlyPropertyAction x:Name="passwordBox2Action" Property="Password"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </PasswordBox>
                    <Button Canvas.Left="150" Canvas.Top="142" Content="Button" Height="23" Name="button11" Width="75" />
                    <validations:CompareValidator Property="{Binding BindablePropertyItem,ElementName=passwordBox2Action}" ErrorMessage="密码不匹配"
                                             ValueToCompare="{Binding BindablePropertyItem,ElementName=passwordBox1Action}"
                                              Source="{Binding ElementName=passwordBox2}"
                                             TriggerElement="{Binding ElementName=button11}"/>
                </Canvas>
            </TabItem>
            <TabItem Header="PassWordMatch">
                <Canvas>
                    <Label Canvas.Left="6" Canvas.Top="37" Content="请输入密码" Height="28" Name="label1" />
                    <Label Canvas.Left="6" Canvas.Top="72" Content="再次输入密码" Height="28" Name="label2" />
                    <TextBox Canvas.Left="105" Canvas.Top="39" Height="23" Name="textBox1" Width="120" />
                    <TextBox Canvas.Left="105" Canvas.Top="72" Height="23" Name="textBox2" Width="120" />
                    <Button Canvas.Left="150" Canvas.Top="142" Content="Button" Height="23" Name="button1" Width="75" />
                    <validations:CompareValidator x:Name="a" Property="{Binding Text,ElementName=textBox2}" ErrorMessage="密码不匹配"
                                             ValueToCompare="{Binding Text,ElementName=textBox1}"
                                            TriggerElement="{Binding ElementName=button1}"/>
                </Canvas>
            </TabItem>
            <TabItem Header="IntCompare">
                <Canvas>
                    <Label Canvas.Left="6" Canvas.Top="37" Content="请输入数字" Height="28" />
                    <Label Canvas.Left="6" Canvas.Top="72" Content="再次输入数字" Height="28"/>
                    <TextBox Canvas.Left="105" Canvas.Top="39" Height="23" Name="tab2_textBox1" Width="120" />
                    <TextBox Canvas.Left="105" Canvas.Top="72" Height="23" Name="tab2_textBox2" Width="120" />
                    <Button Canvas.Left="150" Canvas.Top="142" Content="数字验证" Height="23" Name="tab2_button1" Width="75" />
                    <validations:CompareValidator x:Name="b" Property="{Binding Text,ElementName=tab2_textBox2}" ErrorMessage="数字不匹配"
                                            ValueToCompare="{Binding Text,ElementName=tab2_textBox1}"
                                            Type="{x:Type sys:Double}"
                                            TriggerElement="{Binding ElementName=tab2_button1}"/>
                </Canvas>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>
